#include "argvutils.h"
#include "stringutils.h"

DictVector<string, string> 
argv_utils::parse_to_dict(int argc, char** argv)
{
  DictVector<string, string> ret;
  for (int i = 1; i < argc; i++) {
    string arg = argv[i];
    
    pair<string, string> kv = string_split_to_pair(arg.c_str(), "=");
    string k = kv.first, v = kv.second;
    if (ret.has_key(k)) {
      string* v_ptr = ret.get_ptr(k);
      *v_ptr += "," + v;
    } else {
      ret.push_back(k, v);
    }
  }
  return ret;
}
